/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package game.Rendering;

import game.Helper;
import game.Player.Input;

import java.awt.*;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseListener;
import javax.swing.JPanel;

public abstract class Canvas extends JPanel implements KeyListener, MouseListener {
    protected Rectangle resolution;

    public Canvas() {
        Input input = new Input();
        setDoubleBuffered(true);
        setFocusable(true);
        requestFocus();

    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);

        Graphics2D g2D = (Graphics2D) g;
        onDraw(g2D);

    }

    @Override
    public void keyPressed(KeyEvent e) {
        onKeyPressed(e);
    }

    @Override
    public void keyReleased(KeyEvent e) {
        onKeyUp(e);
    }

    @Override
    public void keyTyped(KeyEvent e) {

    }

    protected abstract void onKeyUp(KeyEvent event);

    protected abstract void onKeyPressed(KeyEvent event);

    protected abstract void onDraw(Graphics2D g2D);

    public Rectangle getResolution(){
        return this.resolution;
    }
}
